<template>
  <div class="loading-page" :class="{ 'fade-out': fadeOut }">
    <div class="loading-content">
      <div class="loading-spinner">
        <a-spin :indicator="indicator" />
      </div>
      <div class="loading-text">{{ text }}</div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { h, ref, onMounted } from 'vue'
import { LoadingOutlined } from '@ant-design/icons-vue'

const props = defineProps({
  text: {
    type: String,
    default: '页面加载中...',
  },
})

const fadeOut = ref(false)
const indicator = h(LoadingOutlined, { style: { fontSize: '48px' }, spin: true })

// 导出方法供父组件调用
const startFadeOut = () => {
  fadeOut.value = true
}

defineExpose({
  startFadeOut,
})
</script>

<style scoped>
.loading-page {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 1;
  transition: opacity 0.5s ease;
}

.loading-page.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loading-content {
  text-align: center;
}

.loading-spinner {
  margin-bottom: 20px;
  color: #1890ff;
}

.loading-text {
  font-size: 16px;
  color: #666;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.6;
  }
}
</style> 